import { defineStore } from 'pinia'
import { ref } from 'vue'
import RESUME_JSON from '@/schema/resume'
import type { IRESUMEJSON } from '@/interface/resume'
import { cloneDeep } from 'lodash'
//小仓库1
export const useResumeJsonStore = defineStore('resumeJsonNew', () => {
  const resume_json = cloneDeep(RESUME_JSON) //简历数据模板
  const resumeJsonNewStore = ref<IRESUMEJSON>(resume_json)
  //修改最初的简历模板的数据
  const changeResumeJsonData = (data: IRESUMEJSON) => {
    resumeJsonNewStore.value = data
  }
  return {
    changeResumeJsonData,
    resumeJsonNewStore,
  }
})

//选中模块仓库
export const useSelectMaterialStore = defineStore('selectMaterial', () => {
  // cptName:"BASE_INFO_1"
  // cptOptionsName:"BASE_INFO_OPTIONS"
  // cptTitle:"基础资料"
  const cptName = ref<string>('')
  const cptOptionsName = ref<string>('')
  const cptTitle = ref<string>('')
  const cptKeyId = ref<string>('') // 选中的模块KeyID
  const modelItem = ref<object>({}) //选中模块对象

  //选择模块
  const updateSelectMaterial = (
    cptNameTxt: string,
    cptOptionsNameTxt: string,
    cptTitleTxt: string,
    cptKeyIdTxt: string,
  ) => {
    cptName.value = cptNameTxt
    cptOptionsName.value = cptOptionsNameTxt
    cptTitle.value = cptTitleTxt
    cptKeyId.value = cptKeyIdTxt
  }

  const resetSelectMaterial = () => {
    cptName.value = ''
    cptOptionsName.value = ''
    cptTitle.value = '全局主题设置'
    cptKeyId.value = ''
  }
  return {
    cptName,
    cptOptionsName,
    cptTitle,
    cptKeyId,
    modelItem,
    updateSelectMaterial,
    resetSelectMaterial,
  }
})
